<template>
	<view>
	<view class="page">
		<view class="header">
			<view class="input-view">
				<uni-icon type="search" size="22" color="#ffffff"></uni-icon>
				<view class='cuIcon-search'></view>
				<input v-model="searchText" confirm-type="搜索" @input="onInput" class="input" type="text" placeholder="输入单号搜索" />
				<view class='cuIcon-scan'></view>
			</view>
			<!-- <view class="icon">
				<uni-icon type="plusempty" color="#ffffff" size="35"></uni-icon>
			</view> -->
		</view>
		<view class="uni-list">
			<view class="uni-list-cell" hover-class="uni-list-cell-hover" @tap="goDetail(item)" v-for="(item,index) in listData"
			 :key="index">
				<view class="uni-media-list">
					<view class="uni-media-list-body">
						<view class="uni-media-list-text-top">
							<text>单号:{{item.inspNo}}</text>
							<text>日期:{{item.inspDate}}</text>
						</view>
						<view class="uni-media-list-text-bottom">

							<!-- <text>{{item.inspType}}</text> -->
							<text style="text-align: end;width: 100%">{{item.inspType_dictText}}</text>
						</view>
					</view>

					<!-- <view class="uni-list-cell-navigate uni-navigate-right"></view> -->
				</view>
			</view>
		</view>
		<!-- <view>
			<navigator url="../huiyuan-add/huiyuan-add">
				<image class="bottom" src="../../../static/wcloud/add.png"></image>
			</navigator>
		</view> -->
	</view>
</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex'
	export default {
		data() {
			return {
				listData:[],
				selFlag:false,
				// inspDate: "2020-07-17"
				// inspNo: "10000003"
				// inspRate: "12"
				// inspType: "iqc"
				// inspType_dictText: "来料检验"
				// remark: "12"
				// sampling: 12
				// sysOrgCode: "A02"

			};
		},
		onLoad(e) {
			console.log(e.selFlag);
			this.selFlag = e.selFlag;
		},
		onLoad: function() {
			let url = '/inspection/inspection/list'
			this.$http.get(url, {
				params: {
					inspDate:"",
					inspNo:"",
					inspType: "",
					inspType_dictText:""
				}
			}).then(res => {
				if (res.data.success) {
					this.listData = res.data.result.records;
				}
			}).catch(err => {
				console.log(err);
			});
			// uni.request({
			// 	url: "https://mc.xmwells.com//jeecg-boot/inspection/inspection/list",
			// 	method: "GET",
			// 	data: {},
			// 	header: {
			// 		"X-Access-Token":1,
			// 	},
			// 	success: res => {
			// 			this.listData= res.data.result.records;
			// 	},
			// });
		},
			// onReachBottom() {
			// console.log("onReachBottom");
			// console.log("endflag" + this.endFlag)
			// if (this.endFlag == true) {
			// 	this.loadMoreText = "已显示全部数据"
			// 	return;
			// }
			// this.showLoadMore = true;
			// setTimeout(() => {
			// 	this.pageNo = this.pageNo + 1;
			// 	this.getList()
			// }, 300);
			// },

			methods: {
				onInput(e) {
					let url = '/inspection/inspection/list'
					this.$http.get(url, {
						params: {
							inspNo:e.detail.value
						}
					}).then(res => {
						if (res.data.success) {
							this.listData = res.data.result.records;
						}
					}).catch(err => {
						console.log(err);
					});

				},
	// 			initData() {
	// // 				uni.showLoading({
	// // 					title: '加载中',
	// // 					mask: false
	// // 				});
	// 				setTimeout(() => {
	// 					this.getList();
	// 					uni.stopPullDownRefresh();
	// 				}, 300);
	// 			},

	// 			getList() {

	// 				let url = this.$url + "soApi/list";

	// 				uni.request({
	// 					url: url,
	// 					method: "POST",
	// 					data: {
	// 						companyCode: this.companyCode,
	// 						pageNo: this.pageNo,
	// 						pageSize: "20",
	// 						filter: this.filter
	// 					},
	// 					header: {
	// 						"X-AUTH-TOKEN": this.$token
	// 					},
	// 					success: res => {
	// 						if (res.statusCode == "200" && res.data.respCode == "0") {
	// 							let data = res.data.data;
	// 							if (data.length < 20) {

	// 								this.endFlag = true;
	// 								this.loadMoreText = "已显示全部数据"
	// 							}
	// 							data.forEach((e) => {
	// //
	// // 								if (e.amount == null || e.amount == "") {
	// // 									e.amount = 0;
	// // 								}
	// 								this.listData.push({
	// 									customerCode: e.customerCode,
	// 									customerDesc: e.customerDesc,
	// 									orderDate: e.orderDate,
	// 									material: e.material,
	// 									description:e.description,
	// 									quantity: e.quantity,
	// 									unit: e.unit,
	// 									id: e.id,
	// 									netValue: e.netValue
	// 								});
	// 							});

	// 						} else {
	// 							// 数据获取失败
	// 						}
	// 					},
	// 					fail: (err) => {
	// 						console.log('request huiyuan list fail', err);
	// 					},
	// 					complete: () => {
	// 						uni.hideLoading();
	// 					}
	// 				});
	// 			},

	// 			postSearch(e) {
	// 				this.listData = [];
	// 				this.endFlag = false;
	// 				this.pageNo = 1;
	// 				this.filter = e.detail.value;
	// 				this.loadMoreText = "加载更多",
	// 					this.getList();
	// 			},
				goDetail: function(e) {
					if (this.selFlag) {
						let  detailData = {
							"inspDate": e.inspDate,
							"inspNo": e.inspNo,
							"inspType_dictText":e.inspType_dictText,
							"remark":e.remark,
							"sysOrgCode":e.sysOrgCode,
						}
						uni.setStorageSync('detailData', detailData);
						uni.navigateBack({
							delta: 1
						});

					} else {
						uni.navigateTo({
							// url: "../huiyuan-update/huiyuan-update?item=" + encodeURIComponent(JSON.stringify(e))
							url: "pinjianUpdata?item=" + JSON.stringify(e)
						})
					}
				}
			}
	}
</script>

<style>
	.header {
		display: flex;
		flex-direction: row;
		padding: 10px 15px;
		align-items: center;
		background-color: #314054;
	}

	.input-view {
		display: flex;
		align-items: center;
		flex-direction: row;
		background-color: #414f61;
		height: 30px;
		border-radius: 15px;
		padding: 0 10px;
		flex: 1;
	}

	.input {
		flex: 1;
		padding: 0 5px;
		height: 24px;
		line-height: 24px;
		font-size: 16px;
		color: #FFFFFF;
	}

	.icon {
		display: flex;
		flex-direction: column;
		justify-content: center;
		margin-left: 10px;
	}

	.bottom {
		position: fixed;
		bottom: 90upx;
		right: 50upx;
		width: 90upx;
		height: 90upx;
	}

	.uni-media-list-text-top {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
	}
	.uni-media-list-text-bottom {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
	}
</style>
